<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        ul {
            margin: 0;
            padding: 0;
            list-style: none;
            /* 1.直接设置一个高 */
            /* height: 50px; */
        }

        /* 2.使用伪元素清除浮动 */
        /* ul::after {
            content: '';
            display: block;
            clear: both;
        } */

        /* 3. */
        /* ul::before,
        ul::after {
            content: '';
            display: table;
            clear: both;
        } */

        /* 4. overflow:hidden 清除浮动 */
        ul {
            overflow: hidden;
        }

        /* 主要用了浮动，一定要给父元素清除浮动 */
        ul li {
            width: 80px;
            height: 50px;
            line-height: 50px;
            background: pink;
            color: #fff;
            text-align: center;
            float: left;
        }

        ul li:hover {
            background: green;
        }
    </style>
</head>

<body>
    <ul>
        <li>新闻1</li>
        <li>新闻2</li>
        <li>新闻3</li>
        <li>新闻4</li>
        <li>新闻5</li>
        <li>新闻6</li>
        <li>新闻7</li>
        <li>新闻8</li>
    </ul>
    1
</body>

</html>